package com.sheyu.mall.order.controller;

import com.sheyu.mall.order.entity.OmsOrderReturnReasonEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author sheyu
 * @Desciption:
 * @date 2020/9/7 10:45 下午
 */
@Slf4j
@RestController
public class RabbitMqController {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @GetMapping("/sendMsg")
    public String sendMsg(){
        for (int i = 0; i < 10; i++) {
            OmsOrderReturnReasonEntity orderReturnReasonEntity = new OmsOrderReturnReasonEntity();
            orderReturnReasonEntity.setId(1L);
            orderReturnReasonEntity.setCreateTime(new Date());
            orderReturnReasonEntity.setName("哈哈哈" + i);
            rabbitTemplate.convertAndSend("shuying-exchange", "shuying", orderReturnReasonEntity);
            log.info("发送消息完成{}", orderReturnReasonEntity);

        }
        return "ok";
    }
}
